<% layout('/layouts/default.html', {title: '任务接收', libs: ['dataGrid']}){ %>
<div class="main-content">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-tools pull-left" style="position: relative">
                <ul class="nav nav-tabs bangPing-tabs">
                    <li ><a href="${ctx}/audit/taskReceive/list">${text('待接收')}</a></li>
                    <li ><a href="${ctx}/audit/taskReceive/list1">${text('进行中')}</a></li>
                    <li ><a href="${ctx}/audit/taskReceive/list3">${text('已完成')}</a></li>
                    <li class="active"><a href="${ctx}/audit/taskReceive/list2">${text('已转办')}</a></li>
                </ul>
            </div>
            <#form:form id="searchForm" model="${taskReceive}" action="${ctx}/audit/taskReceive/listData?transferFlag=1&remarks=4" method="post" class="form-inline"
            data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
            <div style="float: right">
                <div class="form-group">
                    <label class="control-label">${text('任务年度')}：</label>
                    <div class="control-inline width-120">
                        <#form:select path="taskYear" items="${yearList}" blankOption="true" data-placeholder="请选择" itemLabel="yearLabel" itemValue="yearValue" class="form-control width-160" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label">${text('任务标题')}：</label>
                    <div class="control-inline width-160">
                        <#form:input path="taskTitle" placeholder="请输入任务标题"  maxlength="200" class="form-control width-160"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label">${text('任务类型')}：</label>
                    <div class="control-inline width-160">
                        <#form:select path="taskTypeCode" items="${dicts}" blankOption="true" data-placeholder="请选择" itemLabel="dictLabel" itemValue="dictValue" class="form-control width-160"/>
                    </div>
                </div>

                <div class="form-group">
                    <button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
<!--
                    <button type="button" onclick="clickTest()" class="btn btn-primary btn-sm">${text('测试')}</button>
-->
                    <button onclick="cz();" class="btn btn-default btn-sm">${text('重置')}</button>
<!--
                    <button type="button" class="btn btn-primary btn-sm" onclick="exportExcel()">${text('导出')}</button>
-->
                    <button id="changeIcon" type="button" class="btn btn-default btn-sm btnFormMore">${text('高级查询')}<i class="fa fa-angle-double-down" id="changeIcon1"></i></button>
                </div>


                <div class="form-more">
                    <div style="float: right">
                        <div class="form-group">
                            <label class="control-label">${text('任务状态')}：</label>
                            <div class="control-inline width-120">
                                <% var items = [{label:'已接收',value:'2'},{label:'进行中',value:'3'},{label:'已结束',value:'4'}]; %>
                                <#form:select path="taskStatus" items="${items!}" itemLabel="label" itemValue="value" blankOption="true" data-placeholder="请选择任务状态" class="form-control width-120"/>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </#form:form>
    </div>
    <div class="box-body">
        <table id="dataGrid"></table>
        <div id="dataGridPage"></div>
    </div>
</div>
</div>
<% } %>
<script>
    //重置
    function cz(){
        searchForm.reset();
        $('#dataGrid').dataGrid('reloadGrid');
    }

    // 初始化DataGrid对象
    $('#dataGrid').dataGrid({
        searchForm: $("#searchForm"),
        // showCheckbox: true,
        columnModel: [
            // {header:'${text("任务年度")}', name:'taskYear', width:80, align:"center"},
            {header:'${text("督办字号")}', name:'messageNumber', index:'messageNumber', width:140, align:"left"},
            {header:'${text("任务标题")}', name:'taskTitle', width:150, align:"left", frozen:true},
            {header:'${text("任务类型")}', name:'taskTypeName', index:'a.task_type_name', width:150, align:"left"},
            {header:'${text("任务内容")}', name:'taskContent', width:150, align:"left", formatter: function(val, obj, row, act){
                    return '<a href="${ctx}/taskdeploy/dcSupTaskInfo/detailForm?id='+row.taskId+'&actionId='+row.id+'" class="btnList" data-title="${text("督办任务信息")}">'+(val||'暂无内容')+'</a>';
                }},
           /* {header:'${text("牵头领导")}', name:'taskLeaderName', index:'a.task_leader_name', width:150, align:"left"},
            {header:'${text("牵头责任单位")}', name:'leaderOrgName', width:150, align:"center"},*/
            {header:'${text("转办人")}', name:'transferOrgName', width:100, align:"center"},
            // {header:'${text("联系人")}', name:'contactName', width:150, align:"center"},
            {header:'${text("最新待反馈时间")}', name:'feedbackEndTimeStr',index:'feedbackEndTimeStr', width:150, align:"center", formatter: function(val, obj, row, act){
                    if(val) {
                        if (row.colour=='red')  {
                            return '<span style="color:red">' + val + '</span>'
                        }else {
                            return val
                        }
                    }else {
                        return ''
                    }
                }},
            {header:'${text("状态")}', name:'taskStatus', width:80, align:"center",sortable: false, formatter: function(val, obj, row, act){
                    return js.getDictLabel(${@DictUtils.getDictListJson('dc_receive_status')}, val, '${text("未知")}', true);
                }},
            {header:'${text("操作")}', name:'actions', width:300,align:"center", formatter: function(val, obj, row, act){
                    var actions = [];
                    <% if(hasPermi('audit:taskReceive:edit')){ %>
                        actions.push('<a href="${ctx}/audit/taskReceive/taskReceiveFive?isWatch=1&isNewRecord=false&id=' + row.id + '&taskId=' + row.taskId + '" class="btn btn-primary btn-xs btnList" title="${text("查看反馈")}"><span>查看反馈</span></a>&emsp;');
                        if(row.taskStatus!='4') {
                            // actions.push('<a style="cursor:pointer;" onclick=clickTwo("' + row.id + '") class="btn btn-primary btn-xs" title="${text("申请批示")}" ><span>申请批示</span></a>&emsp;');
                            actions.push('<a style="cursor:pointer;" onclick=clickFour("' + row.id + '") class="btn btn-primary btn-xs" title="${text("工作安排")}"><span>工作安排</span></a>&emsp;');
                        }
/*
                    actions.push('<a style="cursor:pointer;" onclick=cuiban("' + row.id + '") class="btn btn-primary btn-xs" title="${text("催办")}" ><span>催办</span></a>&nbsp;');
*/
                    <% } %>
                return actions.join('');
            }}
    ],
    // 加载成功后执行事件
    ajaxSuccess: function(data){

    }
    });
    function clickTwo(id){
        js.layer.open({
            type: 2,
            title: ['申请批示'],
            area: ['800px', '345px'],
            scrollbar: true,
            shadeClose: false,
            content: "${ctx}/audit/taskReceive/taskReceiveTwo?id="+id,
            btn1: function (index, layero) {
            },
            end:function () {
                $('#dataGrid').dataGrid('refresh', 1, 20);
            }
        });
    }
    function clickFour(id){
        js.layer.open({
            type: 2,
            title: ['工作安排'],
            area: ['800px', '200px'],
            scrollbar: true,
            shadeClose: false,
            content: "${ctx}/audit/taskReceive/taskReceiveFour?id="+id,
            btn1: function (index, layero) {
            },
            end:function () {
                $('#dataGrid').dataGrid('refresh', 1, 20);
            }
        });
    }

    function cuiban(id){
        js.loading();
        js.layer.open({
            type: 2,
            title: ['催办'],
            area: ['800px', '400px'],
            scrollbar: true,
            shadeClose: false,
            content: "${ctx}/home/supIndex/cuibanPage?id="+id,
            btn1: function (index, layero) {
            },
            success: function (data) {
                js.closeLoading(0, true);
            },
            end:function () {

            }
        });
        // js.loading("正在催办...");
        // $.ajax({
        //     url: "${ctx}/audit/taskReceive/cuiban",
        //     type: "post",
        //     data: {
        //         "id":id
        //     },
        //     success: function(data){
        //         js.closeLoading(0, true);
        //         js.showMessage(data.message);
        //     },
        //     error: function(data){
        //         js.closeLoading(0, true);
        //         js.showErrorMessage(data.responseJSON.message+"，请联系管理员");
        //     }
        // });
    }
</script>